﻿package com.ljkj.zjf.common;

import java.util.HashMap;
import java.util.Map;

import org.jboss.resteasy.client.ClientRequest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class AccUtil {

	/**
	 * 获取燃气接口数据
	 * 
	 * @param map
	 *            方法名 ，条件
	 * @return result 返回结果
	 */
	@SuppressWarnings("deprecation")
	public String result(Map<String, Object> map) {
		String result = "";
		try {
			ClientRequest client = new ClientRequest(FireConfig.RESOURCE_URL);
			String jsonPara = JSON.toJSONString(map);
			// 对输入参数进行utf-8编码
			String encode_str = java.net.URLEncoder.encode(jsonPara, "utf-8");
			client.body("text/plain", encode_str);
			String returnmsg = client.postTarget(String.class);
			// 对返回结果进行uft-8解码
			result = java.net.URLDecoder.decode(returnmsg, "utf-8");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	public static String searchPaymentServices(String acc_id, String moneymode,
			double pay_money, double owemoney, String pay_id,
			String payreturn_id, String pay_result, String imei, String netid,
			String device_id,String uid,String pay_account) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		AccUtil acc = new AccUtil();
		String msg = "";
		map.put("func_name", "searchPaymentServices");
		map.put("acc_id", acc_id);
		map.put("moneymode", moneymode);

		map.put("pay_account", pay_account);

		map.put("pay_money", pay_money);
		map.put("owemoney", owemoney);
		map.put("payeepid", 0);
		map.put("pay_id", pay_id);
		map.put("payreturn_id", payreturn_id);
		map.put("pay_result", pay_result);
		map.put("imei", imei);
		map.put("netid", netid);
		map.put("device_basic_id", device_id);
		map.put("pay_userid", uid);
		map.put("pay_client_type", "15");
		String result = acc.result(map);
		System.out.println("----------------------->");
		System.out.println(result);
		System.out.println("----------------------->");
		JSONObject para = JSONObject.parseObject(result);
		String code = String.valueOf(para.get("result"));
		if ("0".equals(code)) {
			System.out.println("code：--------支付成功-------------");
		} else {
			System.out.println("错误信息----------------->"
					+ para.get("errmessage"));
			msg = "1";
		}
		return msg;
	}

}
